import collections
class Solution(object):
    def stoneGameIX(self, stones):
        d = collections.defaultdict(int)
        for num in stones:
            d[num % 3] += 1
        max_val, min_val = max(d[1], d[2]), min(d[1], d[2])
        if d[0] % 2:
            if max_val - min_val > 2:
                return True
            else:
                return False
        else:
            if min_val > 0:
                return True
            else:
                return False



